package bsh.compilation;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Representa o resultado de uma compilacao
 * 
 * @author takeshi
 */
public final class CompilationResults implements Serializable {
    private final byte[] bytecode;

    private final long parseTimeMillis;

    private final long compileTimeMillis;

    private final String internalName;

    private final Map<String, byte[]> dependentTypes;

    /**
     * C'tor
     * 
     * @param bytecode o bytecode gerado
     * @param parseTimeMillis o tempo gasto para o parse do script
     * @param compileTimeMillis o tempo gasto para a compilacao da AST
     * @param internalName o nome interno da classe
     * @param dependentTypes the map
     */
    public CompilationResults(byte[] bytecode, long parseTimeMillis, long compileTimeMillis, String internalName,
            Map<String, byte[]> dependentTypes) {
        super();
        this.dependentTypes = new HashMap<String, byte[]>(dependentTypes);
        this.bytecode = bytecode;
        this.parseTimeMillis = parseTimeMillis;
        this.compileTimeMillis = compileTimeMillis;
        this.internalName = internalName;
    }

    /**
     * @return the bytecode
     */
    public byte[] getBytecode() {
        return this.bytecode;
    }

    /**
     * @return the parseTimeMillis
     */
    public long getParseTimeMillis() {
        return this.parseTimeMillis;
    }

    /**
     * @return the compileTimeMillis
     */
    public long getCompileTimeMillis() {
        return this.compileTimeMillis;
    }

    /**
     * @return the className
     */
    public String getInternalName() {
        return this.internalName;
    }

    /**
     * @return String
     */
    public String className() {
        return this.getInternalName().replaceAll("[/]", ".");
    }

    /**
     * @return the dependentTypes
     */
    public Map<String, byte[]> getDependentTypes() {
        return dependentTypes;
    }

}
